/******************************************************************************
 * Copyright (C) 2015  671643387@qq.com
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 *****************************************************************************/

#ifndef SHARED_UTIL_WORLD_PACKET_H_
#define SHARED_UTIL_WORLD_PACKET_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif

#include <cstddef>
#include <cstdint>
#include "node/util/bytebuffer.h"
#include "shared/opcode.h"

class WorldPacket : public ::node::util::ByteBuffer
{
public:
    WorldPacket(void) 
        : ByteBuffer(0), opcode_(MSG_NULL_ACTION)
    {

    }

    explicit WorldPacket(::std::uint16_t opcode, ::std::size_t res = 200)
        : ByteBuffer(res)
        , opcode_(opcode)
    {

    }

    WorldPacket(const WorldPacket& packet)
        : ByteBuffer(packet)
        , opcode_(packet.opcode_)
    {

    }

    virtual ~WorldPacket(void) {}

    void Initialize(::std::uint16_t opcode, ::std::size_t newres = 200)
    {
        Clear();
        storage_.reserve(newres);
        opcode_ = opcode;
    }

    inline ::std::uint16_t get_opcode(void) const {
        return opcode_;
    }
    inline void set_opcode(::std::uint16_t opcode) {
        opcode_ = opcode;
    }
    inline const char *GetOpcodeName(::std::uint16_t opcode) {
        // TODO:
        return NULL;
    }

private:
    ::std::uint16_t opcode_;
};

#endif // SHARED_UTIL_WORLD_PACKET_H_
